
import requests

r= requests.get('https://www.baidu.com')
print(r.encoding)
print(r.content)
print(r.text)

r.encoding='utf-8'
print(2,r.text)
print(3,r.headers)
print(4,r.raw)
print(5,r.json)
print(6,r.url)
print(7,r.status_code)
print(8,r.reason)
print(9,r.raise_for_status())




r=  requests.post("http://httpbin.org/post",data = "{'abc':123}")
print(r.text)
print(r.text)



data = {
    'name': 'tom',
    'age': 20
}


r = requests.get('http://httpbin.org/get', params=data)
print(9,r.text)

print(10,dir(r))
print(10,dir(requests))
'''
r响应数据API
__attrs__
__bool__
__class__
__delattr__,__dict__,__dir__,__doc__
__enter__,__eq__,__exit__
__format__
__ge__,__getattribute__,__getstate__,__gt__
__hash__
__init__,__init_subclass__,__iter__
__le__,__lt__
__module__
__ne__,__new__,__nonzero__
__reduce__,__reduce_ex__,__repr__
__setattr__,__setstate__,__sizeof__,__str__,__subclasshook__
__weakref__
_content,_content_consumed
_next
apparent_encoding
close,connection,content,cookies
elapsed,encoding
headers,history
is_permanent_redirect,is_redirect,iter_content,iter_lines
json
links
next
ok
raise_for_status,raw,reason,request
status_code
text
url
'''

'''
requests常用API
ConnectTimeout,ConnectionError
DependencyWarning
FileModeWarning
HTTPError
JSONDecodeError
NullHandler
PreparedRequest
ReadTimeout,Request,RequestException,RequestsDependencyWarning,Response
Session
Timeout,TooManyRedirects
URLRequired
__author__,__author_email__
__build__,__builtins__
__cached__,__cake__,__copyright__
__description__,__doc__
__file__
__license__,__loader__
__name__
__package__,__path__
__spec__
__title__
__url__
__version__
_check_cryptography
_internal_utils
adapters,api,auth
certs,chardet_version,charset_normalizer_version,check_compatibility,codes,compat,cookies
delete
exceptions
get
head,hooks
logging
models
options
packages,patch,post,put
request
session,sessions,ssl,status_codes,structures
urllib3,utils
warnings
'''
